package day18.cartest;

public class Car1 {
    // 汽车的属性
    private String brand;
    private String model;
    
    // 汽车包含的内部类实例
    private Engine engine;
    private Glass glass;
    private Tire tire;
    
    // 构造函数
    public Car1(String brand, String model) {
        this.brand = brand;
        this.model = model;
        this.engine = new Engine();
        this.glass = new Glass();
        this.tire = new Tire();
    }
    
    // 获取汽车品牌
    public String getBrand() {
        return brand;
    }
    
    // 设置汽车品牌
    public void setBrand(String brand) {
        this.brand = brand;
    }
    
    // 获取汽车型号
    public String getModel() {
        return model;
    }
    
    // 设置汽车型号
    public void setModel(String model) {
        this.model = model;
    }
    
    // 获取发动机
    public Engine getEngine() {
        return engine;
    }
    
    // 获取玻璃
    public Glass getGlass() {
        return glass;
    }
    
    // 获取轮胎
    public Tire getTire() {
        return tire;
    }
    
    // 启动汽车
    public void start() {
        engine.start();
        System.out.println("汽车启动");
    }
    
    // 停止汽车
    public void stop() {
        engine.stop();
        System.out.println("汽车停止");
    }
    
    // 内部类：发动机
    class Engine {
        private String type;
        private int power;
        
        public Engine() {
            this.type = "四冲程发动机";
            this.power = 150;
        }
        
        public void start() {
            System.out.println("发动机启动");
        }
        
        public void stop() {
            System.out.println("发动机停止");
        }
        
        public String getType() {
            return type;
        }
        
        public void setType(String type) {
            this.type = type;
        }
        
        public int getPower() {
            return power;
        }
        
        public void setPower(int power) {
            this.power = power;
        }
    }
    
    // 内部类：玻璃
    class Glass {
        private String type;
        private boolean isTransparent;
        
        public Glass() {
            this.type = "钢化玻璃";
            this.isTransparent = true;
        }
        
        public void clean() {
            System.out.println("清洁玻璃");
        }
        
        public String getType() {
            return type;
        }
        
        public void setType(String type) {
            this.type = type;
        }
        
        public boolean isTransparent() {
            return isTransparent;
        }
        
        public void setTransparent(boolean isTransparent) {
            this.isTransparent = isTransparent;
        }
    }
    
    // 内部类：轮胎
    class Tire {
        private String type;
        private int size;
        private String brand;
        
        public Tire() {
            this.type = "子午线轮胎";
            this.size = 195;
            this.brand = "米其林";
        }
        
        public void inflate() {
            System.out.println("给轮胎充气");
        }
        
        public void replace() {
            System.out.println("更换轮胎");
        }
        
        public String getType() {
            return type;
        }
        
        public void setType(String type) {
            this.type = type;
        }
        
        public int getSize() {
            return size;
        }
        
        public void setSize(int size) {
            this.size = size;
        }
        
        public String getBrand() {
            return brand;
        }
        
        public void setBrand(String brand) {
            this.brand = brand;
        }
    }
}